package com.orkasgb.framework.zookeeper.lock.curator;

import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.retry.RetryNTimes;

/**
 * 用来获取客户端链接
 */
public class ZKCuratorClient {
    private static final String CONNECT_STRING = "172.19.141.10:2181";

    /**
     * 获取客户端链接
     *
     * @return 客户端链接实例
     */
    public static CuratorFramework getZk() {
        CuratorFramework client = CuratorFrameworkFactory.builder().connectString(CONNECT_STRING)
                .sessionTimeoutMs(100 * 1000)
                .retryPolicy(new RetryNTimes(10, 2 * 1000))
                .build();

        client.start();

        return client;
    }
}
